home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: undergrad.math.uwaterloo.ca!clgonsal
- From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
- Subject: Re: Please Please Help! - pointer notation
- Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
- Message-ID: <DnJq4C.pA4@undergrad.math.uwaterloo.ca>
- Date: Thu, 29 Feb 1996 16:36:12 GMT
- References: <4gnlv9$1fh@news.mistral.co.uk>
- Nntp-Posting-Host: lhopital.uwaterloo.ca
- Organization: University of Waterloo
-
- In article <4gnlv9$1fh@news.mistral.co.uk>,
- Mike Barnard <mikebarnard@mistral.co.uk> wrote:
- >Sometimes when prototyping a function the function name is pre-fixed
- >by an asterisk. Why? What does it mean? This is a quote from the
- >pointer tutorial text by Ted Jensen...
-
- A "*" before a function name the way you describe means that it returns a
- pointer. ie:
-
- char *Foo( void );
-
- Foo is a function which returns a pointer to a char, or a "char *".
- Remeber, the above means the same as:
-
- char* Foo( void );
-
- Which might be a little bit easier to understand. (The reason people tend
- to put the space before the * rather than after has to do with the way *'s
- are "bound" to variable names. Of course, this doesn't apply to functions,
- but many people use the same spacing just to be consistent I guess...)
-
- >Putting an asterisk before a variable name declares it as a pointer
- >variable. Putting one before the variable in use means you want to
- >access the data pointed to. Why is there sometimes an asterisk AFTER a
- >variable?
-
- Because you want to multiply it with something?
-
- --
- Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
- Computer Science, University of Waterloo
- http://www.undergrad.math.uwaterloo.ca/~clgonsal/
- http://www.csclub.uwaterloo.ca/~clgonsal/
-